Fixed random number generation that assumed that RAND_MAX == 2147483647. #12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! I'm happy to contribute with a significant improvement to the audio quality of this library. It nagged me that the quality of the demodulated audio was quite "robotic," finally I think I've found one of the reasons: a silly bug in mbelib.c. The code assumes that RAND_MAX == 2147483647, which is not the case for at least the two compilers I'm using here. My RAND_MAX is 32767 and so this bug has the effect of always returning 0 as the random outcome (cannot be denied that it's still random, http://xkcd.com/221/).
With the fix, the quality of the audio is much nicer as can be noticed clearly on the file p25_raw_unencrypted_edf.wav from the dsd-samples repository. This fix also removes the ugly spikes in the output and now the AGC can do a better job.